#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#define endl "\n"
using namespace std;
int k[2005][2005] = { 0 };
int main()
{
	string a, b;
	int an, bn;
	cin >> a >> b;
	an = a.size();
	bn = b.size();
	for (int i = 1; i <= an; i++)
		k[i][0] = i;
	for (int i = 1; i <= bn; i++)
		k[0][i] = i;
	for (int i = 1; i <= an; i++)
	{
		for (int j = 1; j <= bn; j++)
		{
			if (a[i - 1] == b[j - 1])//a是从0开始
				k[i][j] = k[i - 1][j - 1];
			else
				k[i][j] = min({ k[i - 1][j - 1],k[i - 1][j],k[i][j - 1] })+1;//替加减
		}
	}
	cout << k[an][bn] << endl;
	//cout << an << bn;
	return 0;
}
//子问题状态定义：将a中的前i个变为b中的前j个所需要的最小步骤
//状态转换:增删替